package com.sloan.community.repository;

import com.sloan.community.po.Notification;
import org.springframework.data.domain.Pageable;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Repository
public interface NotificationRepository extends R2dbcRepository<Notification, Long> {

    Flux<Notification> findByToUserId(Long toUserId, Pageable pageable);

    Mono<Long> countByToUserId(Long toUserId);

    @Query("update t_notification set status = :status where id = :id")
    Mono<Void> noticeStatus(@Param("id") Long id, @Param("status") Integer status);

    Mono<Long> countByToUserIdAndStatus(Long toUserId,Integer status);
}
